<div class="rightDiv">
  <div class="exciseTableDiv">
    <div class="aRow tableTop" *ngIf="showBtns == 1">
<!--      <button nz-button nzType="primary">-->
<!--        同步-->
<!--      </button>-->
      <button nz-button nzType="primary" (click)="addbtn()">
        <i nz-icon nzType="plus" nzTheme="outline"></i>
        新增
      </button>
    </div>
    <div [ngStyle]="{'margin-top': showBtns != 1 ? '15px' : '0'}">
      <ng-template #totalTemplate let-total>总共 {{ pageInfo.totalRecords? pageInfo.totalRecords:0 }} 条</ng-template>
      <nz-table
        [nzData]="data"
        [nzFrontPagination]="false"
        [nzShowPagination]="true"
        [nzPageIndex]="this.pageInfo.first"
        [nzTotal]="pageInfo.totalRecords"
        [nzShowTotal]="totalTemplate"
        [nzPageSize]="pageInfo.rows"
        [nzLoadingDelay]="1"
        [nzPageSizeOptions]="[10,20,30,50,100]"
        [nzShowQuickJumper]="true"
        [nzShowSizeChanger]="true"
        (nzPageIndexChange)=" this.pageInfo.first = $event;this.page(this.pageInfo)"
        (nzPageSizeChange)="this.pageInfo.rows = $event;this.page(this.pageInfo)"
        nzScroll="false"
      >
        <thead>
        <tr>
          <th>序号</th>
          <th>学年</th>
          <th>学期</th>
          <th>开始时间</th>
          <th>结束时间</th>
          <th nzWidth="160px" *ngIf="showBtns == 1">操作</th>
        </tr>
        </thead>
        <tbody>
        <tr *ngFor="let item of data;let i = index">
          <td>{{i + 1}}</td>
          <td>{{item.schoolYear}}</td>
          <td>{{getSemesterName(item.semester)}}</td>
          <td>{{item.beginTime}}</td>
          <td>{{item.endTime}}</td>
          <td *ngIf="showBtns == 1"><span class="operaFont firOpera"
                    (click)="editApp(item)">
              编辑
            </span>
            <span class="operaFont"
                  nz-popconfirm
                  nzOkType="danger"
                  [nzTitle]="'确定删除'+item.schoolYear+'学年'+getSemesterName(item.semester)+'吗?'"
                  (nzOnConfirm)="delete(item.id)"
                  nzPlacement="top"
            >删除</span>
          </td>
        </tr>
        </tbody>
      </nz-table>
    </div>
  </div>
</div>


<!--学期设置-->
<nz-modal [(nzVisible)]="isSemester"
          nzWidth="535px"
          [nzTitle]="semesterTitle"
          [nzContent]="semesterContent"
          (nzOnCancel)="isSemester = false"
          [nzFooter]="semesterModel"
          nzMaskClosable="false"
>
  <ng-template #semesterTitle>
    {{this.param.id ? '编辑' : '新增'}}学期设置
  </ng-template>
  <ng-template #semesterContent>
    <form nz-form [formGroup]="validateForm">
      <nz-form-item>
        <nz-form-label [nzSm]="5" nzRequired>
          学年
        </nz-form-label>
        <nz-form-control [nzSm]="18">
          <nz-select style="width: 100%;"
                     [(ngModel)]="param.schoolYear"
                     formControlName="schoolYear"
                     (ngModelChange)="schoolYearChange($event)"
                     nzAllowClear nzPlaceHolder="请选择学年"
          >
            <nz-option *ngFor="let item of selectYears"
                       [nzValue]="item.value"
                       [nzLabel]="item.text"
            >
            </nz-option>
          </nz-select>
        </nz-form-control>
      </nz-form-item>
      <nz-form-item>
        <nz-form-label [nzSm]="5" nzRequired>
          学期
        </nz-form-label>
        <nz-form-control [nzSm]="18">
          <nz-select style="width: 100%;"
                     [(ngModel)]="param.semester"
                     formControlName="semester"
                     nzAllowClear nzPlaceHolder="请选择学期"
                     (ngModelChange)="semesterChange($event)"
          >
            <nz-option *ngFor="let item of semesterList"
                       [nzValue]="item.value"
                       [nzLabel]="item.text">
            </nz-option>
          </nz-select>
        </nz-form-control>
      </nz-form-item>
      <nz-form-item>
        <nz-form-label [nzSm]="5" nzRequired>
          选择日期
        </nz-form-label>
        <nz-form-control [nzSm]="18">
          <nz-range-picker style="width: 100%;" formControlName="dateRange"
                           [(ngModel)]="dateRange"></nz-range-picker>
        </nz-form-control>
      </nz-form-item>
    </form>
  </ng-template>
  <ng-template #semesterModel>
    <button nz-button nzType="default"
            (click)="isSemester = false"
    >取消
    </button>
    <button nz-button nzType="primary"
            [disabled]="!validateForm.valid" (click)="submit()"
    >保存
    </button>
  </ng-template>
</nz-modal>
